package com.ljf.service.impl;

import com.ljf.bean.Freight;
import com.ljf.bean.User;
import com.ljf.bean.UserType;
import com.ljf.common.crud.BaseServiceImpl;
import com.ljf.common.utils.Assert;
import com.ljf.mapper.FreightMapper;
import com.ljf.mapper.UserMapper;
import com.ljf.service.FreightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FreightServiceImpl extends BaseServiceImpl<Freight, FreightMapper> implements FreightService {
    @Autowired
    UserMapper userMapper;

    @Override
    public int save(Freight entity) {
        //保存用户
        User user = new User(entity.getAccount(), entity.getPassword(), UserType.FORWARDER_USER);
        int rs=userMapper.save(user);
        Assert.isZero(rs,"货代用户保存失败");
        entity.setId(user.getId());
        return super.save(entity);
    }
}
